<HTML><HEAD><TITLE>session_sql(++Session, ++SQL, -RowProcessedCount)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">library(dbi)</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>session_sql(++Session, ++SQL, -RowProcessedCount)</H1>
Executes a SQL statement on the database server.
<DL>
<DT><EM>Session</EM></DT>
<DD>A session handle
</DD>
<DT><EM>SQL</EM></DT>
<DD>A SQL statement (string)
</DD>
<DT><EM>RowProcessedCount</EM></DT>
<DD>Number of rows affected by this statement
</DD>
</DL>
<H2>Description</H2>
<P>
 Executes a SQL statement (without parameters) on the database server. The
 SQL statement should not have a terminating semicolon (;). If supported by
 the DBMS, SQL can consist of multiple statements separated by semicolons.
 RowProcessedCount will be unified with the number of rows affected by this
 statement.
</P><P>
 In the case of data definition language statements the RowProcessedCount
 parameter is undefined and should be passed as a free variable.
</P><P>
 In the case of data manipulation language statements, the
 RowProcessedCount is the number of rows, deleted, modified or inserted
 by the SQL statement.
</P><P>
 The SQL statement must be valid for the DBMS to execute. It can contain
 NULL characters, i.e. it can contain binary data.
</P><P>
 Any results generated by the statement is discarded.
<H3>Exceptions</H3>
<DL>
<DT><EM>(5) type error </EM>
<DD>Session is not a valid session handle or SQL not a string
<DT><EM>(dbi_error) </EM>
<DD>database returned an error when executing SQL.
</DL>
<H2>Examples</H2>
<PRE>
make_accounts(Session) :-
    session_sql(Session,
        "create table accounts \
         (id           decimal(4)      not null,\
          balance      decimal(9,2)    default 0.0 not null, \
          overdraft    decimal(9,2)    default 0.0 not null \
         )" ,_),
    session_sql(Session,
        "insert into accounts (id,balance) values (1001,1200.0)",1),
    session_sql(Session,
        "insert into accounts (id,balance) values (1002,4300.0)",1).
</PRE>

</BODY></HTML>
